Zadig 文档
Zadig
教程
博客
论坛
关于
中文英文
Zadig
教程
博客
论坛
关于
Zadig v4.2
Loading...
     编辑文档
     反馈问题
     社区讨论

    本页导航

    Code Scanning

    # Create Code Scan

    Request

    POST /openapi/quality/codescan
    
    1

    Body Parameter Description

    Parameter NameDescriptionTypeRequired
    project_keyProject KeystringYes
    nameCode scan namestringYes
    descriptionCode scan descriptionstringNo
    scanner_typeCode scan tool, two options: sonarQube, otherstringYes
    image_nameImage name for scan environmentstringYes
    sonar_systemSonarQube system identifierstringRequired if scanner_type = sonarQube
    repo_infoRepository information[]RepoInfoYes
    addonsDependent package information, fill with empty array if not needed[]AddOnYes
    sonar_parameterCode scan scriptstringNo
    scriptCode scan scriptstringNo
    enable_quality_gateEnable quality gate checkboolYes
    advanced_settingsAdvanced settingsAdvancedSettingsYes

    RepoInfo Parameter Description

    Parameter NameDescriptionTypeRequired
    codehost_nameCode source identifierstringYes
    repo_namespaceRepository namespace (organization/user)stringYes
    repo_nameRepository namestringYes
    branchBranch informationstringYes

    AddOn Parameter Description

    Parameter NameDescriptionTypeRequired
    namePackage namestringYes
    versionPackage versionstringYes

    AdvancedSettings Parameter Description

    Parameter NameDescriptionTypeRequired
    cluster_nameCluster name in resource configurationstringYes
    timeoutTimeout in policy configurationintYes
    resource_specResource configurationResourceSpecYes
    webhooksTrigger configurationWebhooksNo

    ResourceSpec Parameter Description

    Parameter NameDescriptionTypeRequired
    cpu_limitMax CPU resource, unit: mintYes
    memory_limitMax memory resource, unit: MiintYes
    cpu_requestMin CPU resource, unit: mintYes
    memory_requestMin memory resource, unit: MiintYes

    Webhooks Parameter Description

    Parameter NameDescriptionTypeRequired
    enabledWhether to enable triggerboolYes
    hook_listTrigger configuration details[]HookRequired if enabled = true

    Hook Parameter Description

    Parameter NameDescriptionTypeRequired
    codehost_nameCode source identifierstringYes
    repo_namespaceRepository namespace (organization/user)stringYes
    repo_nameRepository namestringYes
    branchTarget branch informationstringYes
    eventsTrigger event types: push, pull_request, tag[]stringYes
    match_foldersFile directories[]stringYes

    Body Parameter Example

    {
        "project_key": "demo",
        "name": "codescan-demo",
        "description": "code scan demo description",
        "scanner_type": "sonarQube",
        "sonar_system": "my-sonar",
        "image_name": "sonar:v1",
        "repo_info": [
            {
                "codehost_name": "github-demo",
                "repo_namespace": "kr-test-org",
                "repo_name": "zadig",
                "branch": "main"
            }
        ],
        "sonar_parameter": "sonar.projectKey=zadig\nsonar.projectName=zadig\nsonar.sources=./cmd/aslan",
        "enable_quality_gate": true,
        "advanced_settings": {
          "cluster_name": "dev-cluster",
          "timeout": 60,
          "resource_spec": {
            "cpu_limit": 1000,
            "memory_limit": 1000,
            "cpu_request": 500,
            "memory_request": 500
          }
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28

    Response

    {
      "message": "success"
    }
    
    1
    2
    3

    # Execute Code Scan Task

    Request

    POST /openapi/quality/codescan/:scanName/task?projectKey=<projectKey>
    
    1

    Query Parameter Description

    Parameter NameTypeDescriptionRequired
    projectKeystringProject KeyYes

    Path Parameter Description

    Parameter NameTypeDescriptionRequired
    scanNamestringCode scan nameYes

    Body Parameter Description

    Parameter NameDescriptionTypeRequired
    scan_reposRepository info[]RepoYes

    Repo Parameter Description

    Parameter NameDescriptionTypeRequired
    branchBranch namestringYes
    repo_nameRepository namestringYes
    repo_ownerOrganization/User namestringYes
    sourceSupported code repository sources:
    github, gitlab, gerrit, codehub, gitee, gitee-enterprise, other
    stringYes
    prsPR number list[]intNo

    Body Parameter Example

    {
        "scan_repos":[
           {
             "branch":"master",
             "repo_name":"voting-app",
             "repo_owner":"kr-test-org1",
             "source":"gitlab",
             "prs":[]
           }
        ]
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11

    Success Response

    Parameter NameTypeDescription
    task_idintCode scan task ID
    {
      "task_id": 27
    }
    
    1
    2
    3

    Failure Response

    {
        "code": 500,
        "description": "mongo: no documents in result",
        "message": "Internal Error: "
    }
    
    1
    2
    3
    4
    5

    # Get Code Scan Task Details

    Request

    GET /openapi/quality/codescan/:scanName/task/:taskID?projectKey=<projectKey>
    
    1

    Path Parameter Description

    Parameter NameTypeDescriptionRequired
    scanNamestringCode scan nameYes
    taskIDintCode scan task IDYes

    Query Parameter Description

    Parameter NameTypeDescriptionRequired
    projectKeystringProject KeyYes

    Success Response

    Parameter NameTypeDescription
    scan_namestringCode scan name
    creatorstringTask creator
    create_timeintTask creation time
    end_timeintTask end time
    task_idintCode scan task ID
    statusstringExecution result
    result_linkstringExecution result link
    repo_info[]RepoRepository info

    Repo Parameter Description

    Parameter NameDescriptionType
    branchBranch namestring
    repo_nameRepository namestring
    repo_ownerOrganization/User namestring
    sourceSupported code repository sources:
    github, gitlab, gerrit, codehub, gitee, gitee-enterprise, other
    string

    Response Example

    {
        "scan_name": "test",
        "creator": "admin",
        "task_id": 10,
        "status": "running",
        "create_time": 1689898942,
        "end_time": 1689898944,
        "result_link": "http://124.23.**.196:9009",
        "repo_info": [
            {
                "repo_owner": "kr-test-org1",
                "source": "gitlab",
                "address": "https://gitlab.com",
                "branch": "main",
                "repo_name": "microservice-demo",
            }
        ]
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18

    Failure Response

    {
        "code": 500,
        "description": "mongo: no documents in result",
        "message": "Internal Error: "
    }
    
    1
    2
    3
    4
    5

    ← TestVersion Management→

    资源
    教程
    论坛
    博客
    公司
    关于
    客户故事
    加入我们
    联系我们
    微信扫一扫
    hello@koderover.com

    © 2026 筑栈(上海)信息技术有限公司 沪 ICP 备 19000177 号 - 1

    •  跟随系统
    •  浅色模式
    •  深色模式
    •  阅读模式